package com.shop.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.JSON2.json.JSONObject;
import com.shop.daoImpl.GoodsDaoImpl;
import com.shop.entity.Goods;

@Service
public class GoodsServiceImpl {
	@Resource(name="goodsDaoImpl")
	private GoodsDaoImpl goodsDaoImpl ;

	public void setGoodsDaoImpl(GoodsDaoImpl goodsDaoImpl) {
		this.goodsDaoImpl = goodsDaoImpl;
	}
	
	public String initPage(Integer id){
		Goods goods = goodsDaoImpl.findById(id) ;
		JSONObject object = new JSONObject() ;
		object.put("id", goods.getId()) ;
		object.put("name", goods.getName()) ;
		object.put("price", goods.getPrice()) ;
		object.put("img", goods.getImgPath()) ;
		object.put("sizes", goods.getSizes()) ;
		object.put("colors", goods.getColors()) ;
		object.put("discount", goods.getDiscount()) ;
		System.out.println(object.toString()) ;
		return object.toString() ;
	}
}
